<template>
    <div class="add-warrper">
        <el-card class="box-card">
            <el-form :inline="true" :model="data.bedInfo" class="demo-form-inline">
                <el-form-item label="床位编号">
                    <el-input v-model="data.bedInfo.bednumber" placeholder="床位编号: 例 1-101 1-102 A区1001.." />
                </el-form-item><br>
                <el-form-item label="所属科室">
                    <el-select v-model="data.bedInfo.department" placeholder="请选择所属科室">
                        <el-option v-for="item in data.departmentInfo" :key="item.id" :label="item.name" :value="item.name"/>
                    </el-select>
                </el-form-item><br>
                <el-form-item label="氧气罐">
                    <el-radio-group v-model="data.bedInfo.oxygen" @change="data.bedInfo.oxygen">
                        <el-radio :label="1">是</el-radio>
                        <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item><br>
                <el-form-item label="心电击">
                    <el-radio-group v-model="data.bedInfo.heart" @change="data.bedInfo.heart">
                        <el-radio :label="1">是</el-radio>
                        <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item><br>
                <el-form-item label="呼吸机">
                    <el-radio-group v-model="data.bedInfo.breath" @change="data.bedInfo.breath">
                        <el-radio :label="1">是</el-radio>
                        <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item><br>
                <el-form-item label="急救设备">
                    <el-radio-group v-model="data.bedInfo.icu" @change="data.bedInfo.icu">
                        <el-radio :label="1">是</el-radio>
                        <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item><br>
                <el-form-item label="空调地暖">
                    <el-radio-group v-model="data.bedInfo.aircondition" @change="data.bedInfo.aircondition">
                        <el-radio :label="1">是</el-radio>
                        <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item><br>
                <el-form-item label="电视外设">
                    <el-radio-group v-model="data.bedInfo.tv"  @change="data.bedInfo.tv">
                        <el-radio :label="1">是</el-radio>
                        <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item><br>
                <el-form-item label="责任护士">
                    <el-select  v-model="data.bedInfo.nurse" placeholder="请选择责任护士">
                        <el-option v-for="item in data.departmentNurse" :key="item.id" :label="item.name" :value="item.name"/>
                    </el-select>
                </el-form-item><br>
                <el-form-item>
                    <el-button type="primary" @click="addBed">确认创建</el-button>
                    <el-button type="info" @click="">返回上一级</el-button>
                </el-form-item>
            </el-form>
        </el-card>
    </div>
</template>

<script setup lang="ts">
import { reactive,watchEffect } from 'vue';
import { getDepatmentReq, getNurseReq,addBedReq } from '@/api/bedmanage/bedmanage'
import { ElMessage } from 'element-plus'

const data = reactive({
    departmentInfo: [],
    departmentName:'',
    departmentBedNum:null,
    departmentNurse:[],
    bedInfo:{
        //床位编号: 例 1-101 1-102 A区1001..
        bednumber:'',
        //所属科室
        department:'',
        //配备氧气罐0否 1是
        oxygen:null,
        //配备心电机0否 1是
        heart:null,
        //配备呼吸机0否 1是
        breath:null,
        //配备急救设备0否 1是
        icu:null,
        //配备空调地暖0否 1是
        aircondition:null,
        //配备电视外设0否 1是
        tv:null,
        //责任护士
        nurse:''
    }
})

//获取科室列表
const getDepatment = async () => {
    const res = await getDepatmentReq()
    data.departmentInfo = res.data.data    
}

//获取护士列表
const getNurseList = async () => {
    const res = await getNurseReq()
    data.departmentNurse = res.data.data
}

//确认创建按钮功能
const addBed = async () => {
    const res = await addBedReq(data.bedInfo)
    console.log(res);
}
    
watchEffect(getDepatment)
watchEffect(getNurseList)
</script>

<style scoped>

</style>